﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOAModels;
using TarreOA.TarreOABLL;
using TarreOA.TarreOADAL;
using System.Data.SqlClient;

public partial class Flow_Info_AppearFeedBack : System.Web.UI.Page
{
    public List<Flow_WorkFeedBack> list_feed;
    public int work_id;
    public int st_so = 1;
    public string allow_affix = "no";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString.Get("WR_ID") != null && Request.QueryString.Get("AL_AF") != null && Request.QueryString.Get("ST_SO") != null)
            {
                work_id = int.Parse(Request.QueryString.Get("WR_ID"));
                allow_affix = Request.QueryString.Get("AL_AF");
                st_so = int.Parse(Request.QueryString.Get("ST_SO"));
                Flow_WorkFeedBack_Service fwpb_service = new Flow_WorkFeedBack_Service();
                list_feed = fwpb_service.FindAllByWorkId(work_id);
                datalistbind();
            }
        }
    }

    /// <summary>
    /// 上传附件datalist绑定方法
    /// </summary>
    private void datalistbind()
    {
        SqlConnection sqlconn = null;
        SqlCommand sqlcmd = null;
        SqlDataReader sqldr = null;
        try
        {
            sqlconn = SQLManager.GetConn();
            string sql = "select id,filename from flow_newworkaffixfile where workid=" + work_id;
            sqlconn.Open();
            sqlcmd = new SqlCommand(sql, sqlconn);
            sqldr = sqlcmd.ExecuteReader();
            if (sqldr.HasRows)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("afid", typeof(string));
                dt.Columns.Add("afname", typeof(string));
                while (sqldr.Read())
                {
                    DataRow dr = dt.NewRow();
                    dr["afid"] = "afdownload.aspx?afid=" + sqldr["id"].ToString();
                    dr["afname"] = sqldr["filename"].ToString();
                    dt.Rows.Add(dr);
                }
                if (dt.Rows.Count > 0)
                {
                    affixfiledlist.DataSource = dt.DefaultView;
                    affixfiledlist.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally
        {
            if (sqlconn != null)
                if (sqlconn.State == ConnectionState.Open)
                {
                    sqlconn.Close();
                    sqlconn.Dispose();
                }
            if (sqldr != null)
            {
                sqldr.Close();
                sqldr.Dispose();
            }
        }
    }
}
